package com.github.apollo.router;

import com.github.apollo.handler.PersonHandler;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;


import static org.springframework.web.reactive.function.server.RouterFunctions.*;

import static org.springframework.web.reactive.function.server.RequestPredicates.*;
/**
 * @author Stephen
 * @since 2018-02-02
 */
public class PersonRouter {


    private PersonHandler personHandler = new PersonHandler();

    public RouterFunction<ServerResponse> rout() {

        return route(POST("/create"), personHandler::create)
            .andRoute(GET("/listAll"), personHandler::listAll)
            .andRoute(GET("/getPerson/{name}"), personHandler::getPerson);
    }
}
